Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for bugs appeared when using function calls with clear history functionality #1531

Merged
merged 27 commits into from
Mar 2, 2024
Merged

Fix for bugs appeared when using function calls with clear history functionality #1531

merged 27 commits into from
Mar 2, 2024

Conversation

GregorD1A1
Copy link
Collaborator

Why are these changes needed?

When started to use manual history feature of GroupChat and agent have made function calls, I found next problems:

  • Autogen exited with errors when agent performed tool call, as reply['content'] is empty in that case. Added appropriate check to if loop.
  • When calling "clear_history" from function reply, tool call message got deleted, leaving tool response message alone, which caused errors from openai. Now it automatically saves last message in that case, so tool call message will not be erased.
  • Having some tool call - tool response pairs i history, when calling "clear history" with "nr_messages_to_preserve" argument could ocassionally break history between tool call and tool response, again causing openai error. Now in such situation tool call message will be also saved.

To sum up, all bugs were fixed.

Checks

@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2024

Codecov Report

Attention: Patch coverage is 94.73684% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 54.64%. Comparing base (d604643) to head (698a443).

Files Patch % Lines
autogen/agentchat/groupchat.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1531       +/-   ##
===========================================
+ Coverage   35.69%   54.64%   +18.95%     
===========================================
  Files          63       63               
  Lines        6625     6637       +12     
  Branches     1454     1581      +127     
===========================================
+ Hits         2365     3627     +1262     
+ Misses       4067     2713     -1354     
- Partials      193      297      +104     
Flag Coverage Δ
unittests 54.61% <94.73%> (+18.91%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GregorD1A1
Copy link
Collaborator Author

Probably need to write test for that improvements, but don't know how to set up agent to call function as default message; any suggestions will be appriciated.

@sonichi sonichi requested review from ekzhu, davorrunje and AaronWard and removed request for davorrunje February 4, 2024 15:51
@GregorD1A1
Copy link
Collaborator Author

@sonichi Is it ok now? Can we merge?

@GregorD1A1
Copy link
Collaborator Author

All remarks improved. Can we solve the PR? @sonichi @ekzhu

@sonichi sonichi enabled auto-merge March 2, 2024 17:37
@sonichi sonichi requested a review from ekzhu March 2, 2024 17:37
@sonichi sonichi added this pull request to the merge queue Mar 2, 2024
Merged via the queue into microsoft:main with commit f2e4232 Mar 2, 2024
50 of 57 checks passed
whiskyboy pushed a commit to whiskyboy/autogen that referenced this pull request Apr 17, 2024
…nctionality (microsoft#1531)

* resolved errors happening when using function calling and clear history

* checking in nr_of_messages_to_preserve were provided

* code formatting

* test added, dict signature improved

* test added, dict signature improved

* test added, dict signature improved

* test added, dict signature improved

* test added, dict signature improved

* test added, dict signature improved

* test added, dict signature improved

* test added, dict signature improved

* Test updated

Co-authored-by: Chi Wang <wang.chi@microsoft.com>

* test improved

* test improved

* comment about preserving additional message added

* commentary about clear history called in tool response improved

* created test for clear hisotry called from tool response

* code formatting

* added 'USER INTERRUPTED' as internal content of tool response

* added separate vatiable 'nr_messages_to_preserve_internal'

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants